﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace MicroFractal.iTunesBrowser.Core.Device
{
    public class SimpleFolderDevice : BaseDevice
    {

        #region Constructor

        public SimpleFolderDevice(string serialId, string name, string path)
            : base(serialId, name)
        {
            DirectorySeparatorChar = Path.DirectorySeparatorChar;

            base.DBRootPath = path;

            if (!Directory.Exists(DBRootPath))
                throw new DevicesNotFoundException();
        }

        #endregion

        #region Attributes


        #endregion

        public override bool IsConnected
        {
            get
            {
                return Directory.Exists(base.DBRootPath);
            }
            protected set
            {
            }
        }

        public override bool CanCancelDownload
        {
            get
            {
                return true;
            }
            protected set
            {
            }
        }

        protected override string ControlFolder
        {
            get { return "iPod_Control"; }
        }
        public override System.IO.MemoryStream GetDBFile()
        {
            MemoryStream m = new MemoryStream();
            byte[] b = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
            m.Write(b, 0, b.Length);
            b =new byte[] {100,0,0,0};
            m.Write(b,0,b.Length);

            return m;
        }

        public override System.IO.MemoryStream GetDBFile(bool refresh)
        {
            return GetDBFile();
        }

        protected override void Download(MicroFractal.iTunesBrowser.Business.Song song, string downloadPath)
        {
            throw new NotImplementedException();
        }

        public override string GetFilePath(MicroFractal.iTunesBrowser.Business.Song song)
        {
            return song.Location;
        }
    }
}
